package com.qdlc.p2p.biz.log.score.convert;

import com.qdlc.p2p.biz.log.score.BaseScoreConvertLog;
import com.qdlc.p2p.common.constant.ScoreTemplateConstant;
import com.qdlc.p2p.common.exception.ScoreException;

/**
 * 积分兑换成功
 */
public class ScoreConvertGoodsSuccessLog extends BaseScoreConvertLog {

	private static final long serialVersionUID = 1L;
	
	private String logTemplateNid = ScoreTemplateConstant.SCORE_CONVERT_GOODS_VERIFY_SUCCESS;
	
	public ScoreConvertGoodsSuccessLog() {
		super();
	}

	public ScoreConvertGoodsSuccessLog(long userId, int score) {
		super(userId, score, ScoreTemplateConstant.SCORE_CONVERT_GOODS_VERIFY_SUCCESS);
		this.setLogTemplateNid(logTemplateNid);
	}

	@Override
	public void modifyScore() {
		Boolean result = scoreDao.updateScore(this.getUser().getUserId(), 0, 0, this.getScore(), -this.getScore());
		if(!result){
			throw new ScoreException("更新用户积分失败！", 1);
		}
	}
	
}
